package com.king.security.interceptor;

import com.king.security.entity.MyUser;

/**
 * 前端登录用户信息上下文
 *
 * @author yangli
 */
public class LoginUserVoContext {

    /***
     * 线程局部变量
     */
    private static ThreadLocal<MyUser> localLoginUserVo = new ThreadLocal<MyUser>();

    public static MyUser getLoginUserVo() {
        return localLoginUserVo.get();
    }

    public static Long getUserId() {
        return getLoginUserVo() == null ? null : getLoginUserVo().getId();
    }

    public static void setLoginUserVo(MyUser loginUserVo) {
        localLoginUserVo.set(loginUserVo);
    }

    public static void removeLoginUserVo() {
        localLoginUserVo.remove();
    }
}
